package cn.com.roy.thread.t7_2_7.grouprecursetest;

public class Run {
    public static void main(String[] args) {
        ThreadGroup mainGroup = Thread.currentThread().getThreadGroup();
        ThreadGroup groupA = new ThreadGroup(mainGroup,"A");
        Runnable runnable = new Runnable() {
            public void run() {
                System.out.println("runMethod!");
            }
        };
        ThreadGroup groupB =  new ThreadGroup(groupA,"B");
        ThreadGroup[] listGroup1 = new ThreadGroup[Thread.currentThread().getThreadGroup().activeGroupCount()];
        Thread.currentThread().getThreadGroup().enumerate(listGroup1,true);
        for (int i = 0; i < listGroup1.length; i++) {
            if(listGroup1[i] != null){
                System.out.println(listGroup1[i].getName());
            }
        }

        System.out.println("----------------------");
        ThreadGroup[] listGroup2 = new ThreadGroup[Thread.currentThread().getThreadGroup().activeGroupCount()];
        Thread.currentThread().getThreadGroup().enumerate(listGroup2,false);
        for (int i = 0; i < listGroup2.length; i++) {
            if(listGroup2[i] != null){
                System.out.println(listGroup2[i].getName());
            }
        }
    }
}
